Skip to content

Conversation

@UrazAkgultan
Copy link
Collaborator

Description

This PR adds conditional terser minification based on the presence of react-native-reanimated dependency.

Changes

  • Dynamically detect react-native-reanimated in package.json dependencies/peerDependencies
  • When reanimated is detected:
    • Apply full terser configuration with both mangle and compress disabled
    • Preserve function names and class names for worklet compatibility
  • When reanimated is not present:
    • Apply minimal terser configuration with only mangle disabled
  • Skip terser entirely in non-production builds

Motivation

React Native Reanimated requires specific minification settings to preserve worklet functions and their context. This change ensures proper terser configuration is applied automatically based on project dependencies.

Testing

  • Tested with widgets using react-native-reanimated
  • Tested with widgets without react-native-reanimated
  • Verified production and development builds

@UrazAkgultan UrazAkgultan requested a review from a team as a code owner October 23, 2025 07:55
@UrazAkgultan UrazAkgultan changed the base branch from main to version/mx/10 October 23, 2025 07:55
@karahanharunn karahanharunn requested a review from Copilot October 23, 2025 08:33
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements dynamic terser configuration for React Native builds based on the detection of react-native-reanimated as a dependency. When reanimated is present, terser applies comprehensive minification settings that preserve worklet function names and classes required for reanimated's functionality. Without reanimated, minimal terser configuration is applied.

Key Changes:

  • Added runtime detection of react-native-reanimated in package.json dependencies/peerDependencies
  • Implemented conditional terser configuration with full preservation settings for reanimated projects
  • Maintained backward compatibility with minimal terser settings for non-reanimated projects
Comments suppressed due to low confidence (1)

patches/@mendix+pluggable-widgets-tools+10.15.0+002+conditional-terser-for-reanimated.patch:1

  • The hasReanimated constant is recalculated on every call to getCommonPlugins. Since package.json dependencies don't change during the build process, this check should be moved outside the function to avoid redundant file system reads and JSON parsing.
diff --git a/node_modules/@mendix/pluggable-widgets-tools/configs/rollup.config.native.js b/node_modules/@mendix/pluggable-widgets-tools/configs/rollup.config.native.js

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@UrazAkgultan UrazAkgultan merged commit c005c36 into version/mx/10 Oct 23, 2025
89 of 97 checks passed
@UrazAkgultan UrazAkgultan deleted the fix/conditional-terser-reanimated-mx10 branch October 23, 2025 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants